package com.yxjme.myseekbar;


import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import com.yxjme.seekbarlibrary.BidirectionalSeekBar;
import com.yxjme.seekbarlibrary.MySeekBar;

public class MainActivity extends AppCompatActivity {


    MySeekBar mMySeekBar;
    EditText ed1,ed2;
    float  price  =  450f;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ed1 = findViewById(R.id.ed1);
        ed2 = findViewById(R.id.ed2);
        mMySeekBar = findViewById(R.id.mMySeekBar);
        mMySeekBar.setOnChangerProgressListener(listener);




        final BidirectionalSeekBar bSeekBar1 = findViewById(R.id.bSeekBar1);
        bSeekBar1.setWithInColor(Color.YELLOW);
        bSeekBar1.setWithOutColor(Color.GRAY);
        bSeekBar1.setOnSeekBarChangeListener(new BidirectionalSeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(int leftProgress, int rightProgress) {
                Log.v("====Path=======","minVal="+leftProgress+",maxVal="+rightProgress);
            }
        });
        findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                bSeekBar1.setProgress(30,80);
            }
        });
    }


    MySeekBar.OnChangerProgressListener listener = new MySeekBar.OnChangerProgressListener() {
        @Override
        public void onProgress(float minVal, float maxVal) {
            Log.v("====Path=======","minVal="+minVal+",maxVal="+maxVal);
            ed1.setText(""+(int)(minVal*price));
            ed2.setText(""+(int)(maxVal*price));
        }
    };

}